<?php

    if (!defined('BASEPATH'))
        exit('No direct script access allowed');

    if (!function_exists('find_tax')) {

        function find_tax($tax, $nr_nights, $adults, $ages) {

            $myTax = new tax_calculation();
            $myTax->set_tax_row($tax);
            $myTax->set_nr_adults($adults);
            $myTax->set_nr_nights($nr_nights);
            $myTax->set_nr_childrens(count($ages));
            $myTax->set_ages($ages);

            $tax_row = $myTax->calculate();
            unset($myTax);

            $tax_row['total'] = $tax_row['insurance'] + $tax_row['city'] + $tax_row['eco'];

            return $tax_row;
        }

    }
    